package com.bianguo.android.apushdemo.presenter.impl;

import com.bianguo.android.apushdemo.entity.MovieEntity;
import com.bianguo.android.apushdemo.model.ModelFactory;
import com.bianguo.android.apushdemo.model.impl.MovieModelImpl;
import com.bianguo.android.apushdemo.utils.MyLog;
import com.bianguo.android.apushdemo.view.IMovieView;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/4/21.
 */

public class MoviePresenterImpl {

    private IMovieView movieView;
    private MovieModelImpl movieModel;

    public MoviePresenterImpl(IMovieView movieView){
        this.movieView = movieView;
        movieModel = ModelFactory.getFactory().createMovieModel();
    }

    public void showMoviePresenter() {
        movieModel.showMovie(new Subscriber<MovieEntity>() {

            @Override
            public void onNext(MovieEntity movieEntity) {
                movieView.showMovieView(movieEntity);
            }

            @Override
            public void onCompleted() {
                MyLog.mLog("onCompleted");
            }

            @Override
            public void onError(Throwable t) {
                MyLog.mLog("onError :" + t.getMessage());
                movieView.failMovieView();
            }

        });
    }
}
